
import http from '@ohos.net.http';
import { ShopInfo } from '../viewmodel/shop/ShopInfo';

class ShopModel{

  baseUrl:string = 'https://www.leadfund.com.cn/api/provider/product/type'

  pageNo:number=1
  getShopList():Promise<ShopInfo[]>{

    return new Promise((resolve,reject) =>{

      //创建http请求
      let httpRequest =  http.createHttp()
      //发送请求
      httpRequest.request(
        this.baseUrl,
        {method:http.RequestMethod.GET}
      ).then(resp =>{
        if (resp.responseCode ==200) {
          console.log('查询商铺信息成功！result:',resp.result.toString())
          resolve(JSON.parse(resp.result.toString()))

        }else {
          console.log('查询商铺信息失败！error:',JSON.stringify(resp))
          reject('查询商铺信息失败')
        }
      })
        .catch(error =>{
          console.log('查询商铺信息失败！error:',JSON.stringify(error))
          reject('查询商铺信息失败')
        })
    })

  }
}

const  shopModel = new ShopModel();
export default shopModel as ShopModel;